home *** CD-ROM | disk | FTP | other *** search
- Path: news.cencom.net!ns!tanp
- From: tanp@ns (Bill Wendling)
- Newsgroups: comp.lang.c
- Subject: Re: Halp! I don't know what I'm doing wrong!
- Date: 4 Feb 1996 07:15:25 GMT
- Organization: Cen-Com Internet
- Message-ID: <4f1med$oio@news.cencom.net>
- References: <4eu8sl$f27@aphex.direct.ca>
- NNTP-Posting-Host: ns.cencom.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- Ed Toivanen inexplicably wrote:
- } I've been at this for a couple *days* and can't get it to work.
- } It's supposed to graph a function entered at the command line,
- } eg. "c:\>graph 2 1" should graph out 2x+1 to stdout using the '*'
- } character. Can anybody help me please?
- } I'll name all my kids after you!(when I have 'em that is!)
-
- } /*
- } Ed Toivanen
- } Comp3425
- } Assign1
- } */
-
- } #include <stdio.h>
- } #include <stdlib.h>
-
- } #define DOMAN 80
- } #define DCORR 40/* shift right, to
- } keep in domain of array*/
- } #define RANGE 40
- } #define RCORR 20/* shift up, to
- } keep in range of array*/
-
- } long power(long, int);
-
- } int main(int argc, char **argv){
- } long minDomain = -DOMAN/2;
- } long maxDomain = DOMAN/2-1;
- } long minRange = -RANGE/2;
- } long maxRange = RANGE/2-1;
- } static char lin[RANGE][DOMAN];
- } long x, y=0;
- } long degree, argctemp=argc;
-
- /*
- Define a temporary variable:
- char **tmp = argv;
- */
-
- } if(argc < 2){
- } printf("Usage %s <coefficients>\n", *argv);
- } return(0);
- } }
- }
- } for(x=minDomain; x<maxDomain; x++){
- } degree = argc - 1;
- } while(degree--){
- } y = ((atol(*++argv)) * (power(x, degree))) + y;
- /*
- Replace above line with:
- y += ((atol(*++tmp)) * (power(x, degree)));
- */
- } if(y > maxRange || y < minRange)
- } y = 0;
- } }
- /*
- Add this line here:
- tmp = argv;
- */
- } lin[ y + RCORR][x + DCORR] = '*';
- } }
- }
- } for(y=maxRange; y>minRange; y--){/*from top down*/
- } for(x = minDomain; x < maxDomain; x++){
- } printf("%c", lin[y + RCORR][x + DCORR]);
- /*
- You might want to consider changing this to:
- printf("%s", lin[y + RCORR]);
- */
- } }
- } printf("\n");
- } }
- } return(0);
- } }
-
- } long power(long num, int degree){/* for positive,
- } whole powers*/
- } long product = 1L;
- }
- } if(degree==0 && num==0)
- } return(0L);
- } if(degree==0)
- } return(1L);
- } while(degree--){
- } product *= num;
- } }
- } return(product);
- } }
-
-
- --
- Bill Wendling | "Pinky, are you thinking what I'm thinking?"
- tanp@ns.cencom.net | "I think so, Brain, but burlap chafes me so."
- "Boom Shanka" | Finger me for my Geek Code...NOW!
-